package icu.sehnen.user.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;

/**
 * <p>
 * 后台用户权限表
 * </p>
 *
 * @author icu.sehnen
 * @since 2021-04-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(excludeProperty = "children")
@ApiModel(value="Permission对象", description="后台用户权限表")
public class Permission implements Serializable, GrantedAuthority {

    private static final long serialVersionUID = 1L;
    private  Long id;
    @ApiModelProperty(value = "父级权限id")
    private Long pid;

    @ApiModelProperty(value = "名称")
    private String name;


    @ApiModelProperty(value = "图标")
    private String icon;

    @ApiModelProperty(value = "权限类型：0->目录；1->菜单；2->按钮（接口绑定权限）")
    private Integer type;

    @ApiModelProperty(value = "前端资源路径")
    private String path;

    @ApiModelProperty(value = "启用状态；0->禁用；1->启用")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
//    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
//    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private Date createTime;

    List<Permission> children;

    @ApiModelProperty(value = "排序")
    private Integer sort;


    @Override
    public String getAuthority() {
        return  this.path;
    }

    public void setAuthority(String path){

    }

}
